from machine import Pin, ADC


class Soil:
    def __init__(self, pinA0, pinD0) -> None:
        adc = ADC(pinA0)
        adc.atten(ADC.ATTN_11DB)
        adc.width(ADC.WIDTH_12BIT)
        self.__pinA0 = adc
        self.__pinD0 = Pin(pinD0, Pin.IN)

    def read_analog(self):
        return self.__pinA0.read()

    def read_digital(self):
        return self.__pinD0.value()


if __name__ == "__main__":
    import time

    s = Soil(1, 2)

    while True:
        print(s.read_analog(), s.read_digital())
        time.sleep(2)
